﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TaskManageDemo.Data.Entitys
{
    public class ScheduleTask:BaseEntity
    {
        public string TaskName { get; set; }
        public string ClassName { get; set; }
        public string CreateTime { get; set; }
        public string LastTime { get; set; }
        public string NextTime { get; set; }
        public bool Allowused { get; set; }
        public string CronExpression { get; set; }
        public string Remark { get; set; }


        #region 重载运算符
        /// <summary>
        /// 比较两个运行计划是否相等
        /// </summary>
        public static bool operator ==(ScheduleTask task1, ScheduleTask task2)
        {
            bool t1IsNull = object.ReferenceEquals(task1, null);
            bool t2IsNuLL = object.ReferenceEquals(task2, null);
            if (t1IsNull && t2IsNuLL) return true; //两个为真返回true
            if (t1IsNull || t2IsNuLL) return false; //一个为假返回false

            //两个都不为空，比较属性
            return
                task1.CronExpression == task2.CronExpression &&
                task1.Id == task2.Id &&
                task1.ClassName == task2.ClassName &&
                task1.Remark == task2.Remark &&
                task1.TaskName == task2.TaskName&&
                task1.CreateTime==task2.CreateTime;
        }

        /// <summary>
        /// 比较两个运行计划是否相等
        /// </summary>
        public static bool operator !=(ScheduleTask task1, ScheduleTask task2)
        {
            bool t1IsNull = object.ReferenceEquals(task1, null);
            bool t2IsNuLL = object.ReferenceEquals(task2, null);
            if (t1IsNull && t2IsNuLL) return true; //两个为真返回true
            if (t1IsNull || t2IsNuLL) return false; //一个为假返回false

            //两个都不为空，比较属性
            return
                task1.CronExpression != task2.CronExpression ||
                task1.Id != task2.Id ||
                task1.ClassName != task2.ClassName ||
                task1.Remark != task2.Remark ||
                task1.TaskName != task2.TaskName||
                task1.CreateTime != task2.CreateTime;
        }
        #endregion

    }
}
